<?php
(!defined('IN_TOA') || !defined('IN_ADMIN')) && exit('Access Denied!');
/*
	[天生创想] (C)2008-2011 515158 Inc.
	This is NOT a freeware, use is subject to license terms
    URL:http://www.515158.com/
*/



empty($do) && $do = 'list';
if ($do == 'list') {
	//列表信息 
	$wheresql = '';
	$page = max(1, getGP('page','G','int'));
	$pagesize = 20;
	$offset = ($page - 1) * $pagesize;
	$url = 'admin.php?ac=isindex&fileurl=conference&type='.$_GET[type].'';

	if ($keyword = getGP('keyword','G')) {
		$wheresql .= " AND subject LIKE '%$keyword%'";
		$url .= '&keyword='.rawurlencode($keyword);
	}
		
	if(!is_superadmin()){
	$wheresql = "and (attendance like'%".GET_INC_USER_NAME($_USER->id)."%' or uid='".$_USER->id."' or recordperson ='".$_USER->id."')";
	}
	
	//会议
	if ($subject = getGP('subject','G','int')) {
		$wheresql .= " AND conferenceid ='".$subject."'";
		$url .= '&subject='.$subject;	
	}
	//时间
	$vstartdate = getGP('vstartdate','G');
	$venddate = getGP('venddate','G');
	if ($vstartdate!='' && $venddate!='') {
		$wheresql .= " AND (date>='".$vstartdate."' and date<='".$venddate."')";
	$url .= '&vstartdate='.$vstartdate.'&venddate='.$venddate;
	}
	
	$num = $db->result("SELECT COUNT(*) AS num FROM ".DB_TABLEPRE."conference_record WHERE 1 $wheresql");
     $sql = "SELECT * FROM ".DB_TABLEPRE."conference_record WHERE 1 $wheresql ORDER BY rid desc LIMIT $offset, $pagesize";
	$result = $db->fetch_all($sql);

	include_once('template/isindex.php');

} elseif ($do == '删 除') {
get_config_keytable("istration_conference_record_delete");

	$idarr = getGP('id','P','array');
	foreach ($idarr as $id) {
	$db->query("DELETE FROM ".DB_TABLEPRE."conference_record WHERE rid = '$id'");
	$content=$id;
	$title='删除会议记录';
	get_oa_log_dbadd($id,$content,$title,19,$_USER->id);	
	}
	goto_page('admin.php?ac=isindex&fileurl=conference&message=1&type='.$_GET[type].'');

} 


//读部门


function get_conference_options($selid = 0) {
	global $db;
	$html = '';
	$sql = "SELECT id,title FROM ".DB_TABLEPRE."conference order by id desc";
	$query = $db->query($sql);
	while ($row = $db->fetch_array($query)) {
		$selstr = $row['id'] == $selid ? 'selected="selected"' : '';
		$html .= '<option value="'.$row['id'].'|oa'.$row['title'].'" '.$selstr.' >'.$row['title'].'</option>';
	}
	return $html;
}
?>